package cn.org.xuanzp.nty.server.handler;

import cn.org.xuanzp.common.command.Command;

/**
 * @Classname NtyHandler
 * @Description TODO
 * @Version 1.0.0
 * @Date 2024/9/23 0:15
 * @Created by xuanzp
 */
public class NtyHandler {
    private CommandHandler routeCommandHandler;
    private CommandHandler transmitCommandHandler;

    public NtyHandler(CommandHandler routeCommandHandler, CommandHandler transmitCommandHandler) {
        this.routeCommandHandler = routeCommandHandler;
        this.transmitCommandHandler = transmitCommandHandler;
    }

    public NtyHandler(CommandHandler routeCommandHandler) {
        this.routeCommandHandler = routeCommandHandler;
        this.transmitCommandHandler = new TransmitCommandHandler();
    }

    public void route(Command command){
        routeCommandHandler.handler(command);
    }

    public void transmit(Command command){
        transmitCommandHandler.handler(command);
    }

    public CommandHandler getRouteCommandHandler() {
        return routeCommandHandler;
    }

    public void setRouteCommandHandler(CommandHandler routeCommandHandler) {
        this.routeCommandHandler = routeCommandHandler;
    }

    public CommandHandler getTransmitCommandHandler() {
        return transmitCommandHandler;
    }

    public void setTransmitCommandHandler(CommandHandler transmitCommandHandler) {
        this.transmitCommandHandler = transmitCommandHandler;
    }
}
